class Solution {
public:
    int minCut(string s) {
        int n = s.size();
        vector<vector<bool>>f(n, vector<bool>(n));
        for (int i = n - 1; i >= 0; i--) {
            for (int j = i; j < n; j++) {
                if (s[i] != s[j])continue;
                f[i][j] = i + 1 < j ? f[i + 1][j - 1] : 1;
            }
        }
        cout << f[0][2] << endl;
        cout << f[0][1] << endl;
        vector<int>dp(n, INT_MAX);
        for (int i = 0; i < n; i++) {
            if (f[0][i])dp[i] = 0;
            else {
                for (int j = 1; j <= i; j++) {
                    if (f[j][i])dp[i] = min(dp[i], dp[j - 1] + 1);
                }
            }
        }
        return dp[n - 1];
    }
};